Skip to content

Conversation

@arielvalentin
Copy link
Contributor

@arielvalentin arielvalentin commented Nov 6, 2025

Ensures that all HTTP client gems support unknown methods as described in semantic conventions: https://opentelemetry.io/docs/specs/semconv/http/http-spans/#http-client-span

Some concessions:

  1. This change intentionally introduces structural and knowledge duplication in each client gem as a first step refactoring to extract and move the functionality into a shared helper gem or the semantic conventions gem.
  2. The HttpHelper produces a bit of primitive obsession by adding a struct that is used to copy to semconv attributes
  3. I am deferring updating span naming to the latest guidance to a future PR
  4. I am deferring supporting OTEL_INSTRUMENTATION_HTTP_KNOWN_METHODS environment variable to a future PR

See #1779

Comment on lines +66 to +69
def self.span_attrs_for(method, semconv: :stable)
normalized = METHOD_CACHE[method]
if normalized
span_name = semconv == :old ? OLD_SPAN_NAMES[normalized] : normalized
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arielvalentin - I'm concerned about changing the span names and attributes for the "old" instrumentation. It seems to break the contract for the OTEL_SEMCONV_STABILITY_OPT_IN var:

The default behavior (in the absence of one of these values) is to continue emitting whatever version of the old experimental HTTP and networking conventions the instrumentation was emitting previously.
(source)

What do you think about reverting the changes for the old modules and leaving the changes for dup and new?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok that makes sense. I can leave the span name alone in follow up PRs.

Please consider that the existing old implementation does not follow the correct conventions for span names and should not have a prefix of HTTP:

HTTP spans MUST follow the overall guidelines for span names. HTTP server span names SHOULD be {http.method} {http.route} if there is a (low-cardinality) http.route available. HTTP server span names SHOULD be {http.method} if there is no (low-cardinality) http.route available. HTTP client spans have no http.route attribute since client-side instrumentation is not generally aware of the "route", and therefore HTTP client spans SHOULD use {http.method}. Instrumentation MUST NOT default to using URI path as span name, but MAY provide hooks to allow custom logic to override the default span name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may provide hooks to allow custom logic to override the default span name is also something new to me 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants